<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务，帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件，不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types=1);

namespace app\api\controller;

use think\response\Json;
use app\api\model\IndexBanner as IndexBannerModel;
use app\api\model\IndexType as IndexTypeModel;
use app\api\service\IndexBanner as IndexBannerService;
use app\api\service\User as UserService;
use cores\exception\BaseException;
use app\store\model\User as UserModel;

/**
 * 首页管理
 * Class User
 * @package app\api
 */
class IndexBanner extends Controller
{
    /**
     * 获取首页信息
     * @return Json
     * @throws BaseException
     */
    public function info(): Json
    {
 

        $IndexBannerService = new IndexBannerService;
        // 当前用户信息
        $IndexList = $IndexBannerService->getIndexBannerList();

        return $this->renderSuccess(compact('IndexList'));

    }

    //验证用户是否极客会员
/*     private function is_jeek_users(){
        // 获取header请求中的token
        $java_token = $this->request->header('Authorization');
        $is_geek_users =  $this->is_jeek_users($java_token); // 0是普通会员,1是极客会员
        if($is_geek_users == 1){ //当前用户是极客会员的时候会员等级升级为极客会员
            // 获取当前用户ID
            $userId = UserService::getCurrentLoginUserId();
            // 用户详情
            $model = UserModel::detail($userId);
            $post = array('grade_id'=>1,'remark'=>'自动升级极客会员');
            if ($model->setGrade($post)) {
                return $this->renderSuccess('操作成功');
            }
        }
           
        $httpApiUrl = $this->app->config->get('app.httpApiUrl');
        $url = $httpApiUrl."api/whethermember";
        //header请求参数
        $header  = array(
            'Authorization:'. $java_token,
        );
        $res =  json_decode(b5curl_get($url,$header),true);
        if(isset($res['data']) && $res['code']==200){
            return $res['data'];
        }else{
            return $this->renderError('验证是否会员失败: code'.$res['code'].'msg'.$res['msg']);
        }
    } */

   
}
